const { createStore } = require('redux')

// reducer
const defaultState = {
  count: 0
}
const reducer = (state = defaultState, { type }) => {
  switch(type) {
    case 'add':
      return {
        count: state.count + 1
      }
    default:
      return state
  }
}

const reducer2 = (state = defaultState, { type }) => {
  switch(type) {
    case 'add':
      return {
        count: state.count + 100
      }
    default:
      return state
  }
}

const store = createStore(reducer)

store.replaceReducer(reducer2)

store.subscribe(() => {
  console.log(store.getState())
})

store.dispatch({
  type: 'add'
})
store.dispatch({
  type: 'add'
})